package com.example.schoolhospitalsystem;



import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class DoctorScheduleActivity extends AppCompatActivity {

    private TextView tvSchedule;
    private Button btnImportSchedule, btnExportSchedule;
    private String doctorId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_doctor_schedule);

        // 获取医生ID
        Intent intent = getIntent();
        doctorId = intent.getStringExtra("doctorId");

        tvSchedule = findViewById(R.id.tv_schedule);
        btnImportSchedule = findViewById(R.id.btn_import_schedule);
        btnExportSchedule = findViewById(R.id.btn_export_schedule);

        // 导入排班数据按钮点击事件
        btnImportSchedule.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 导入排班数据
                if (importScheduleData()) {
                    Toast.makeText(DoctorScheduleActivity.this, "排班数据导入成功", Toast.LENGTH_SHORT).show();
                    // 更新排班显示
                    updateScheduleDisplay();
                } else {
                    Toast.makeText(DoctorScheduleActivity.this, "排班数据导入失败", Toast.LENGTH_SHORT).show();
                }
            }
        });

        // 导出排班数据按钮点击事件
        btnExportSchedule.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 导出排班数据
                if (exportScheduleData()) {
                    Toast.makeText(DoctorScheduleActivity.this, "排班数据导出成功", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(DoctorScheduleActivity.this, "排班数据导出失败", Toast.LENGTH_SHORT).show();
                }
            }
        });

        // 初始化显示排班数据
        updateScheduleDisplay();
    }

    private boolean importScheduleData() {
        // 这里应该实现从文件导入排班数据到数据库的逻辑
        // 简化示例，直接返回导入成功
        return true;
    }

    private boolean exportScheduleData() {
        // 这里应该实现从数据库导出排班数据到CSV文件的逻辑
        // 简化示例，直接返回导出成功
        return true;
    }

    // DoctorScheduleActivity.java
    private void updateScheduleDisplay() {
        // 这里应该从数据库获取医生的排班数据
        // 简化示例，显示更多模拟数据
        String scheduleData = "张医生 排班表\n\n" +
                "2025-07-02: 上午\n" +
                "2025-07-03: 全天\n" +
                "2025-07-04: 休息\n" +
                "2025-07-05: 下午\n" +
                "2025-07-06: 上午\n" +
                "2025-07-07: 全天\n" +
                "2025-07-08: 休息\n" +
                "2025-07-09: 上午\n" +
                "2025-07-10: 下午";

        tvSchedule.setText(scheduleData);
    }
}